namespace CaltechSoft.Service.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class CustomerEquipment : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.CustomerEquipments",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EquipmentId = c.Int(nullable: false),
                        CustomerId = c.Int(nullable: false),
                        SerialNumber = c.String(),
                        PONumber = c.String(),
                        Procedure = c.String(),
                        AssetNumber = c.String(),
                        CalibrationDate = c.DateTime(),
                        NextDueDate = c.DateTime(),
                        Price = c.Long(),
                        CreatedBy = c.String(),
                        CreatedDate = c.DateTime(),
                        UpdatedDate = c.DateTime(),
                        UpdatedBy = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Customers", t => t.CustomerId, cascadeDelete: true)
                .ForeignKey("dbo.Equipment", t => t.EquipmentId, cascadeDelete: true)
                .Index(t => t.EquipmentId)
                .Index(t => t.CustomerId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.CustomerEquipments", "EquipmentId", "dbo.Equipment");
            DropForeignKey("dbo.CustomerEquipments", "CustomerId", "dbo.Customers");
            DropIndex("dbo.CustomerEquipments", new[] { "CustomerId" });
            DropIndex("dbo.CustomerEquipments", new[] { "EquipmentId" });
            DropTable("dbo.CustomerEquipments");
        }
    }
}
